import * as _ from "lodash"
import httpClient from "../httpclient"

export enum CarrierCode {
  SF = "sf", // 顺丰
  ZTO = "zto", // 中通
  STO = "sto", // 申通
  YTO = "yto" // 圆通
}

export class Carrier {
  public name: string
  public code: CarrierCode
}

export class CarrierService {
  public static getCarriers(): Promise<Carrier[]> {
    return httpClient.get(`/v1/carriers`)
      .then(({ data }) => _.map(data, carrier => _.assign(new Carrier(), carrier)))
  }
}
